package com.zyh.number;

import java.util.Scanner;

public class NumberDemo2 {
    //随堂练习
    //1.键盘录入一个String类型的年龄"18",将年龄加1后，在输出新的字符串年龄："19"
    public static void main(String[] args) {
        System.out.println("请输入一个年龄：");
        String age = new Scanner(System.in).next();
        int age1 = Integer.parseInt(age);
        age1++;
        age = Integer.toString(age1);
        System.out.println("age = " + age);
    }

    public static void main1(String[] args) {
        //字符串转基本类型
        int num1 = Integer.parseInt("100");
        System.out.println("num1 = " + num1);
        double num2 = Double.parseDouble("3.14D");
        System.out.println("num2 = " + num2);
        boolean aTrue = Boolean.parseBoolean("True");
        System.out.println("aTrue = " + aTrue);
        //基本类型转为字符串
        int num = 10;
        String str1 = num + "";
        System.out.println("str1 = " + str1);
        String s = Integer.toString(num);
        System.out.println("s = " + s);


    }
}
